﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script src="/js/header.js"></script>
</head>
<body style="background-color: white;">
    <div class="data-wrap">
        <div class="data-tool clearfix">
            <div class="pull-left form-inline ">
            </div>
            <div class="pull-right">
                <form class="form-inline" id="formSearch" onsubmit="return false;">
                    <input class="form-control" name="paymentRecordId" type="hidden" />
                    <input class="form-control" name="originalPaymentCardId" type="hidden" />
                    <div class="input-group input-group-sm wd200 f_l">
                        <label class="input-group-addon m5_l">银行名称：</label>
                        <input class="form-control" name="bankName" type="text" autocomplete="off" />
                    </div>
                    <div class="input-group input-group-sm wd200 f_l m5_l">
                        <label class="input-group-addon m5_l">用户名：</label>
                        <input class="form-control" name="cardName" type="text" autocomplete="off">
                    </div>
                    <div class="input-group input-group-sm wd250 f_l m5_l">
                        <label class="input-group-addon m5_l">银行卡号：</label>
                        <input class="form-control" name="CardNumber" type="text" autocomplete="off" />
                    </div>
                    <button type="button" class="btn btn-default btn-sm active f_r" id="btnSearch"><span class="glyphicon glyphicon-search"></span> 搜索</button>
                </form>
            </div>
        </div>
        <div class="paging">
        </div>
    </div>
    <script type="text/x-dot-template" id="templatePager">
        <div class="data-body data-scroll">
            <div class="data-view">
                <div class="data-div-view table-responsive">
                    <table class="table table-hover table-striped table-bordered">
                        <thead>
                            <tr>
                                <th class="wd30"></th>
                                <th class="t_l wd100">公司名称</th>
                                <th class="t_l wd100">银行名称</th>
                                <th class="t_l wd125">银行卡号</th>
                                <th class="t_l wd100">用户名</th>
                                <th class="t_c wd75">启用状态</th>
                                <th class="t_r bold wd75">参考余额</th>
                                <th class="t_r wd150">付款区间起迄</th>
                                <th class="wd75">跨行转账</th>
                            </tr>
                        </thead>
                        <tbody>
                            {{? it.tData && it.tData.length>0}}
                            {{~it.tData :item:index}}
                            <tr>
                                <td class="wd30"><input type="radio" name="bankCardId" value="{{=item.bcId}}" /></td>
                                <td class="t_l wd100" title="{{= item.companyNameEn }}">{{= item.companyName }}</td>
                                <td class="t_l wd100" title="{{= item.bankName }}">{{= item.bankName }}</td>
                                <td class="t_l wd125" title="{{= FlashPay.Util.SubCardNumber(item.cardNumber) }}">{{= FlashPay.Util.SubCardNumber(item.cardNumber) }}</td>
                                <td class="t_l wd100">{{= item.cardName }}</td>
                                <td class="t_c wd75">
                                    {{? item.enableStatus==1 }}
                                    <span class="green bold">启用</span>
                                    {{?? item.enableStatus==2}}
                                    <span class="red bold">禁用</span>
                                    {{??}}
                                    <span class="red bold">删除</span>
                                    {{? }}
                                </td>
                                <td class="t_r bold wd75">{{?  item.balance}}{{= item.balance }}{{??}}{{?}}</td>
                                <td class="t_r wd150">{{?  item.paymentInterval}}{{= item.paymentInterval }}{{??}}{{?}}</td>
                                <td class="wd75">
                                    {{? item.crossBankPay==1 }}
                                    同行
                                    {{?? item.crossBankPay==2}}
                                    跨行
                                    {{??}}
                                    全部
                                    {{? }}
                                </td>
                            </tr>
                            {{~}}
                            {{??}}
                            <tr class="noRecord">
                                <td colspan="9">暂无记录！</td>
                            </tr>
                            {{?}}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- 必要的分页参数设置 -->
        <input type="hidden" id="TotalCount" value="{{=it.totalCount}}" />
    </script>
    <script type="text/javascript">
        var paymentRecordId = "";
        var originalPaymentCardId = "";

        $(function () {

            paymentRecordId = FlashPay.Util.GetQueryString("paymentRecordId");
            originalPaymentCardId = FlashPay.Util.GetQueryString("originalPaymentCardId");

            $("input[name='paymentRecordId']").val(paymentRecordId);
            $("input[name='originalPaymentCardId']").val(originalPaymentCardId);

            FlashPay.UI.DataAutoHeight();

            $("#btnSearch").click(function () {

                window.currentPage = null;

                doSearch();
            });

            FlashPay.UI.DoSearch();
        });

        $(document).keyup(function (event) {
            var keycode = event.which;
            if (keycode == 13) {
                FlashPay.UI.DoSearch();
            }
        });

        function doSearch() {
            FlashPay.UI.Pager(".paging", { templateId: "templatePager", pageSize: 10, ajax: { url: '/Payment/CompanyPaymentCard' } });
        }

        function save() {

            var paymentCardId = $('input:radio[name="bankCardId"]:checked').val();

            if (FlashPay.Util.isNullOrEmptySpance(paymentCardId)) {
                FlashPay.UI.Tip_short_warning("请选择一张付款卡！");
                return false;
            }

            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            FlashPay.Util.Ajax({
                type: "POST",
                url: "/Payment/RenewMatchCard",
                data: { PaymentRecordId: paymentRecordId, OriginalPaymentCardId: originalPaymentCardId, PaymentCardId: paymentCardId },
                dataType: "json",
                success: function (response) {
                    if (response != null && response.success) {
                        FlashPay.UI.DialogOpener().Tip_success("操作成功！");
                        FlashPay.UI.DialogOpener().doSearch();
                        FlashPay.UI.CloseDialog();
                    } else {
                        cover.Remove();
                        FlashPay.UI.DialogOpener().Tip_short_warning("操作失败:" + response.errorMessage);
                        FlashPay.UI.DialogOpener().doSearch();
                        FlashPay.UI.CloseDialog();
                    }
                },
                error: function (e) {
                    cover.Remove();

                    FlashPay.UI.Tip_short_warning("操作失败！请查看网络，请重试！");
                }
            });

            
        }
    </script>
</body>
</html>